/*
 * Copyright (c) 2020-2021, SERI Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2022-05-22     Lyons        first version
 */

// interger width
`define INT_WIDTH               8'd32

// float width
`define FLOAT_WIDTH             8'd64
`define EXPN_WIDTH              8'd11
`define FRAC_WIDTH              8'd52

// single float width
`define SINGLE_WIDTH            8'd32
`define SINGLE_EXPN_WIDTH       8'd8
`define SINGLE_FRAC_WIDTH       8'd23

// double float width
`define DOUBLE_WIDTH            8'd64
`define DOUBLE_EXPN_WIDTH       8'd11
`define DOUBLE_FRAC_WIDTH       8'd52

// cNan qNan sNan Inf normal subnormal zero
// 6    5    4    3   2      1         0
`define TYPE_WIDTH              8'd7

// unit select
`define SEL_UNIT_FALU           3'b001
`define SEL_UNIT_FMAU           3'b010
`define SEL_UNIT_FDSU           3'b100

// if sel_unit[2]=FDSU
//  9       8
//  div     sqrt
// 
//  10_0000_0000:   FDIV
//  01_0000_0000:   FSQRT

`define SEL_FUNC_FDIV           10'b1000000_000
`define SEL_FUNC_FSQRT          10'b0100000_000

// if sel_unit[1]=FMAU
//  9       8       7       6
//  mul     mac     neg     sub
//
//  10_0000_0000:   FMUL
//  01_ab00_0000:   ab=00 is FMADD
//                  ab=01 is FMSUB
//                  ab=10 is FNMADD
//                  ab=11 is FNMSUB

`define SEL_FUNC_FMUL           10'b1000000_000

`define SEL_FUNC_FMADD          10'b0100000_000
`define SEL_FUNC_FMSUB          10'b0101000_000
`define SEL_FUNC_FNMADD         10'b0110000_000 //not support yet
`define SEL_FUNC_FNMSUB         10'b0111000_000 //not support yet

// if sel_unit[1]=FALU
//  9       8       7       6       5       4       3       [2   1   0]
//  sub/add sel     cmp     mv      sgnj    cnvt    class   append-func
//
//  00_0000_0/000:  FADD
//  10_0000_0/000:  FSUB
//  01_0000_0/0ab:  ab=01 is FMAX
//                  ab=10 is FMIN
//  00_1000_0/0ab:  ab=01 is FEQ
//                  ab=10 is FLT
//                  ab=11 is FLE
//  00_0100_0/0ab:  ab=01 is FMV.X.W
//                  ab=10 is FMV.W.X
//  00_0010_0/0ab:  ab=00 is FSGNJ
//                  ab=01 is FSGNJN
//                  ab=10 is FSGNJX
//  00_0001_0/abc:  abc=000 is FCVT.D.S
//                        1 is FCVT.S.D
//                  abc=100 is FCVT.W.{D|S}
//                        1 is FCVT.WU.{D|S}
//                  abc=010 is FCVT.{D|S}.W
//                        1 is FCVT.{D|S}.WU
//  00_0000_1/000:  FCLASS

`define SEL_FUNC_FADD           10'b0000000_000

`define SEL_FUNC_FSUB           10'b1000000_000

`define SEL_FUNC_FMAX           10'b0100000_001 //not support yet
`define SEL_FUNC_FMIN           10'b0100000_010 //not support yet

`define SEL_FUNC_FEQ            10'b0010000_001 //not support yet
`define SEL_FUNC_FLT            10'b0010000_010 //not support yet
`define SEL_FUNC_FLE            10'b0010000_011 //not support yet

`define SEL_FUNC_FMVXW          10'b0001000_001
`define SEL_FUNC_FMVWX          10'b0001000_010

`define SEL_FUNC_FCVTDS         10'b0000010_000
`define SEL_FUNC_FCVTSD         10'b0000010_001
`define SEL_FUNC_FCVTIF         10'b0000010_101 //only support unsigned, to double fixed
`define SEL_FUNC_FCVTFI         10'b0000010_011 //only support unsigned

`define SEL_FUNC_FSGNJ          10'b0000100_000
`define SEL_FUNC_FSGNJN         10'b0000100_001
`define SEL_FUNC_FSGNJX         10'b0000100_010

`define SEL_FUNC_FCLASS         10'b0000001_000